﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;

namespace broker.duty.XHRS
{
    class Class2
    {
        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Period > 0)
            {
                double f = (double)ppa.SchemePeriodActing.SchemeActing.GetAuxConfigValue("分红率(预估)");

                ppa.Amount += ppa.PolicyActing.PeriodActings[ppa.Period - 1].Amount * f;
            }

            if (ppa.Period == 0)
            {
                if (ppa.SchemePeriodActing.InsurantStates.Contains("疾病身故"))
                {
                    da.Value = ppa.Amount * 0.1 + ppa.TotalFee;
                    ppa.SchemePeriodActing.InsurantStates.Add("身故");
                    ppa.IsCurrentFinish = true;
                }else if(ppa.SchemePeriodActing.InsurantStates.Contains("全残"))
                {
                    da.Value = ppa.Amount * 0.1 + ppa.TotalFee;
                    ppa.SchemePeriodActing.InsurantStates.Add("身故");
                    ppa.IsCurrentFinish = true;
                }
                else if (ppa.SchemePeriodActing.InsurantStates.Contains("意外身故"))
                {
                    da.Value = ppa.Amount;
                    ppa.SchemePeriodActing.InsurantStates.Add("身故");
                    ppa.IsCurrentFinish = true;
                }
            }
            else
            {
                if (ppa.SchemePeriodActing.InsurantStates.Contains("疾病身故") || ppa.SchemePeriodActing.InsurantStates.Contains("意外身故"))
                {
                    da.Value = ppa.Amount;
                    ppa.SchemePeriodActing.InsurantStates.Add("身故");
                    ppa.IsCurrentFinish = true;
                }
                else if (ppa.SchemePeriodActing.InsurantStates.Contains("全残"))
                {
                    da.Value = ppa.Amount;
                    ppa.IsCurrentFinish = true;
                }
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Period > 0)
            {
                double f = (double)ppa.SchemePeriodActing.SchemeActing.GetAuxConfigValue("分红率(预估)");

                ppa.Amount += ppa.PolicyActing.PeriodActings[ppa.Period - 1].Amount * f;
            }


            if(ppa.Period==(ppa.PolicyActing.PeriodActings.Count()-1))
            {
                da.Value=ppa.Amount;
            }

        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Period == 0)
            {
                if (ppa.SchemePeriodActing.InsurantStates.Contains("疾病身故"))
                {
                    da.Value = ppa.Amount * 0.1 + ppa.TotalFee;
                    ppa.SchemePeriodActing.InsurantStates.Add("身故");
                    ppa.IsCurrentFinish = true;
                }
                else if (ppa.SchemePeriodActing.InsurantStates.Contains("全残"))
                {
                    da.Value = ppa.Amount * 0.1 + ppa.TotalFee;
                    ppa.IsCurrentFinish = true;
                }
                else if (ppa.SchemePeriodActing.InsurantStates.Contains("意外身故"))
                {
                    da.Value = ppa.Amount *2;
                    ppa.SchemePeriodActing.InsurantStates.Add("身故");
                    ppa.IsCurrentFinish = true;
                }
            }
            else
            {
                if (ppa.SchemePeriodActing.InsurantStates.Contains("疾病身故") || ppa.SchemePeriodActing.InsurantStates.Contains("意外身故"))
                {
                    da.Value = ppa.Amount * 2;
                    ppa.SchemePeriodActing.InsurantStates.Add("身故");
                    ppa.IsCurrentFinish = true;
                }
                else if (ppa.SchemePeriodActing.InsurantStates.Contains("全残"))
                {
                    da.Value = ppa.Amount *2;
                    ppa.IsCurrentFinish = true;
                }
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("重疾"))
            {
                if (ppa.Period == 0)
                {
                    da.Value = ppa.Amount * 0.1 + ppa.TotalFee;
                }
                else
                {
                    da.Value = ppa.Amount * (1 + (0.05 * (ppa.Period + 1)));

                }
                ppa.IsCurrentFinish = true;
            }

        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("疾病身故"))
            {
                if (ppa.Period == 0)
                {
                    da.Value = ppa.Amount * 0.1 + ppa.TotalFee;
                }
                else
                {
                    da.Value = ppa.Amount * (1 + (0.05 * (ppa.Period + 1)));

                }
                ppa.IsCurrentFinish = true;
            }
            else if (ppa.SchemePeriodActing.InsurantStates.Contains("意外身故"))
            {
                da.Value = ppa.Amount * (1 + (0.05 * (ppa.Period + 1)));
                ppa.IsCurrentFinish = true;
            }

        }

    }
}
